<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <!-- 引入样式 -->
  <link rel="stylesheet" href="../../plugins/element-ui/index.css" />
  <link rel="stylesheet" href="../../styles/common.css" />
  <link rel="stylesheet" href="../../styles/page.css" />
  <link rel="stylesheet" href="../../styles/style.css">
  <style>
    .is-selected {
      color: #1989FA;
    }
  </style>
</head>
<body>
<div class="dashboard-container" id="category-app">
  <div>
    <el-calendar style="width: 50%; height: 50%;">
      <!-- 这里使用的是 2.5 slot 语法，对于新项目请使用 2.6 slot 语法-->
      <template
              slot="dateCell"
              slot-scope="{date, data}">
        <p :class="data.isSelected ? 'is-selected' : ''">
          {{ data.day.split('-').slice(1).join('-') }}
        </p>
        <div
                v-for="(sign, index) in signList"
                :key="index"
        >
          <div v-if="data.day == sign.time">
             ✔️
          </div>
        </div>
      </template>
    </el-calendar>
  </div>
  <div style="width: 300px; height: 300px;  margin: 0 auto;">
    <div style="width: 200px; height: 200px;line-height: 200px; border-radius: 50%;background-color: #1E90FF;
           font-size: 50px; color: #fff; text-align: center; cursor: pointer; box-shadow: 0 0 30px rgba(0,0,0 ,2);
           float: right" @click.prevent="signs">
      签到
    </div>
  </div>
</div>
  <script type="text/javascript" src="https://api.map.baidu.com/api?v=1.0&&type=webgl&ak=q9ms5g4EG970C0ZRtduxl00srGtyCeNA"></script>
    <!-- 开发环境版本，包含了有帮助的命令行警告 -->
    <script src="../../plugins/vue/vue.js"></script>
    <!-- 引入组件库 -->
    <script src="../../plugins/element-ui/index.js"></script>
    <!-- 引入axios -->
    <script src="../../plugins/axios/axios.min.js"></script>
    <script src="../../js/request.js"></script>
    <script src="../../api/category.js"></script>
    <script src="../../api/details.js"></script>
    <script>
      new Vue({
        el: '#category-app',
        data() {
          return {
              selectedDate:'',
              signList:[]
          }
        },
        computed: {},
        created() {
          this.init()
        },
        mounted() {

        },
        methods: {
          init(){
            getSignDate().then(res => {
              if (String(res.code) === '1') {
                console.log(res.data)
                this.signList = res.data
                //获取今天的日期
                let date = new Date().getDate();
                let fullYear = new Date().getFullYear();
                let month = new Date().getMonth() + 1;
                let dayDate = fullYear + '-0' + month + '-' + date
                this.selectedDate = dayDate
                /*for (let i = 0; i < this.signList.length; i++) {
                  console.log("6666",dayDate)
                  console.log("6666",this.signList)
                  if (dayDate == this.signList[i].time){
                    console.log("5555",dayDate)
                    this.selectedDate = true

                  }
                  console.log("selectedDate",this.selectedDate)
                }*/
              } else {
                this.$message.error(res.msg || '操作失败')
              }
            })
          },
          signs() {
            console.log('signs() 方法被触发了')
            const location = localStorage.getItem("location")
            sign(location).then(res => {
              if (String(res.code) === '1') {
                console.log(res.data)
                this.$message.success("打卡成功")
                // this.ruleForm.password = ''
              } else {
                this.$message.error(res.msg || '操作失败')
              }
            })
          }
        }
      })
    </script>
</body>
</html>